import type { BasicColumn, FormSchema } from '@/components/Table'
import { useRender } from '@/components/Table'
import { DICT_TYPE, getDictOptions } from '@/utils/dict'

export const columns: BasicColumn[] = [
  {
    title: '编号',
    dataIndex: 'id',
    width: 160,
  },
  {
    title: '名字',
    dataIndex: 'name',
    width: 160,
  },
  {
    title: '性别',
    dataIndex: 'sex',
    width: 160,
    customRender: ({ text }) => {
      return useRender.renderDict(text, DICT_TYPE.SYSTEM_USER_SEX)
    },
  },
  {
    title: '出生年',
    dataIndex: 'birthday',
    width: 180,
    customRender: ({ text }) => {
      return useRender.renderDate(text)
    },
  },
  {
    title: '简介',
    dataIndex: 'description',
    width: 160,
  },
  {
    title: '头像',
    dataIndex: 'avatar',
    width: 160,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
    customRender: ({ text }) => {
      return useRender.renderDate(text)
    },
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    label: '名字',
    field: 'name',
    component: 'Input',
    colProps: { span: 8 },
  },
  // {
  //   label: '性别',
  //   field: 'sex',
  //   component: 'Radio',
  //   componentProps: {
  //     options: [],
  //   },
  //   colProps: { span: 8 },
  // },
  {
    label: '出生年',
    field: 'birthday',
    component: 'RangePicker',
    colProps: { span: 8 },
  },
  {
    label: '简介',
    field: 'description',
    component: 'Input',
    colProps: { span: 8 },
  },

  {
    label: '创建时间',
    field: 'createTime',
    component: 'RangePicker',
    colProps: { span: 8 },
  },
]

export const createFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input',
  },
  {
    label: '名字',
    field: 'name',
    required: true,
    component: 'Input',
  },
  {
    label: '用户性别',
    field: 'sex',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.SYSTEM_USER_SEX),
    },
  },

  // {
  //   label: '性别',
  //   field: 'sex',
  //   required: true,
  //   component: 'RadioButtonGroup',
  //   componentProps: {
  //       options:[],
  //   },
  // },
  {
    label: '出生年',
    field: 'birthday',
    required: true,
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'x',
    },
  },
  {
    label: '简介',
    field: 'description',
    required: true,
    component: 'Editor',
  },
  {
    label: '头像',
    field: 'avatar',
    component: 'Input',
  },
]

export const updateFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input',
  },
  {
    label: '名字',
    field: 'name',
    required: true,
    component: 'Input',
  },
  {
    label: '用户性别',
    field: 'sex',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.SYSTEM_USER_SEX),
    },
  },
  {
    label: '出生年',
    field: 'birthday',
    required: true,
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'x',
    },
  },
  {
    label: '简介',
    field: 'description',
    required: true,
    component: 'Editor',
  },
  {
    label: '头像',
    field: 'avatar',
    component: 'Input',
  },
]
